<?php

use doumiaoduo\layer\LayerConfirmWidget;
use doumiaoduo\layer\LayerIframeWidget;
use common\components\helpers\Fun;
use common\components\extenders\MenuManage;

use doumiaoduo\layer\LayerAsset;

LayerAsset::register($this);

LayerConfirmWidget::widget();
LayerIframeWidget::widget();
?>
    <div class="yx-cnt-box yx-praise-content yx-radius2">
        <div class="yx-praise-box">
            <a href="<?= $backUrl ?>" class="btn yx-back-list yx-radius5 ">返回上级</a>
            <div class="yx-member-info">
                <h3 class="yx-pb15">会员基本信息:</h3>
                <table class="yx-member-box" style="width:100%;">
                    <tr>
                        <td class="yx-padding15" rowspan="5" width="120"><img
                                    src="<?= !empty($model->logo) ? $model->logo : '/images/images/noperson.png' ?>"
                                    style="width:90px;height:90px;padding:2px;border:1px #e1e1e1 solid;">
                            <h3 class="yx-font14 text-center yx-pt6"><?= $model->nick_name ?></h3></td>
                        <td bgcolor="#f8f8f8">会员姓名</td>
                        <td><?= $model->name ?></td>
                        <td bgcolor="#f8f8f8">性别</td>
                        <td><?= $model->sex == 'Male' ? '男' : '女' ?></td>
                        <td bgcolor="#f8f8f8">等级</td>
                        <td><?= isset($BAccout->grade_id) ? isset($grades[$BAccout->grade_id]) ? $grades[$BAccout->grade_id] : '普通会员' : '普通会员' ?></td>
                        <td>益智类金额</td>
                        <td><?= isset($BAccout->puzzle_cash) ? $BAccout->puzzle_cash : 0 ?></td>
                    </tr>
                    <tr>
                        <td bgcolor="#f8f8f8">年龄</td>
                        <td><?php
                            $age = '';
                            if ($model->age > 0) {
                                $age = (int)date('Y') - $model->age;
                            }
                            echo $age;
                            ?>岁
                        </td>
                        <td bgcolor="#f8f8f8">电话</td>
                        <td><?= $model->mobile ?></td>
                        <td bgcolor="#f8f8f8">卡号</td>
                        <td><?= $model->card_id ?></td>
                        <td>音乐类金额</td>
                        <td><?= isset($BAccout->music_cash) ? $BAccout->music_cash : 0 ?></td>
                    </tr>
                    <tr>
                        <td bgcolor="#f8f8f8">账户</td>
                        <td><?= isset($BAccout->cash) ? $BAccout->cash : 0 ?></td>
                        <td bgcolor="#f8f8f8">奖学金</td>
                        <td><?= isset($BAccout->scholarship_available) ? $BAccout->scholarship_available : 0 ?></td>
                        <td bgcolor="#f8f8f8">加入时间</td>
                        <td><?= \Yii::$app->formatter->asDatetime($model->created_at) ?></td>
                        <td>形体类金额</td>
                        <td><?= isset($BAccout->body_cash) ? $BAccout->body_cash : 0 ?></td>
                    </tr>
                    <tr>
                        <td colspan="8"
                            style="padding:5px 16px 8px 12px;text-align: right;"><?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'card', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bg79dae3 yx-width67 yx-mr5 yx-mb0 yx-radius2', 'data' => ['id' => \Yii::$app->request->get('id'), 'name' => '开卡']]); ?>
                            <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'change', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bg89c997 yx-width78 yx-mr5 yx-mb0 yx-radius2', 'data' => ['id' => \Yii::$app->request->get('id'), 'name' => '修改资料']]); ?>
                            <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'charge', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bgf8b551 yx-width67 yx-mr5 yx-mb0 yx-radius2', 'data' => ['id' => \Yii::$app->request->get('id'), 'name' => '充值']]); ?>
                            <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'orderproduct', true, ['rel' => 'orderproduct', 'class' => 'btn yx-classmagage-about yx-bg6accbf yx-width67 yx-radius2 yx-mr5 yx-mb0', 'data' => ['id' => \Yii::$app->request->get('id')]]); ?>

                            <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'consume', false, ['rel' => 'consume', 'class' => 'btn yx-classmagage-about yx-bg7ecdf4 yx-width67 yx-mr5 yx-mb0 yx-radius2 ', 'data' => ['id' => \Yii::$app->request->get('id')]]); ?>
                            <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'order', false, ['rel' => 'consume', 'class' => 'btn yx-classmagage-about yx-bg7ecef4 yx-width67 yx-radius2 yx-mr5 yx-mb0', 'data' => ['id' => \Yii::$app->request->get('id')]]); ?>
                            <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'bindcard', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bg88abda yx-width67 yx-radius2 yx-mr0 yx-mb0', 'data' => ['id' => \Yii::$app->request->get('id'), 'name' => '绑卡']]); ?>
                        </td>
                    </tr>
                    <tr>
                        <td bgcolor="#f8f8f8">备注</td>
                        <td colspan="5"><?php if (!($model->remarks === 0)) { ?>
                                <?= $model->remarks ?>
                            <?php } ?></td>
                        <td colspan="3" style="padding:5px 16px 8px 12px;text-align: right;">
                            <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'remarks', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bg7ecef4 yx-width67 yx-radius2 yx-mr0 yx-mb0', 'data' => ['id' => \Yii::$app->request->get('id'), 'name' => '备注']]); ?>
                        </td>
                    </tr>
                </table>
            </div>

            <div class="yx-member-info">
                <h3 class="yx-pb15">学员信息:</h3>
                <table class="yx-member-box" style="width: 100%">
                    <?php if ($student): ?>
                        <tr>
                            <td rowspan="5" width="120">
                                <?php if (!empty($student->img)) { ?>
                                    <img src="<?php echo $student->img ?>" width="100" style="width:90px;height:90px;padding:2px;border:1px #e1e1e1 solid;">
                                <?php } ?>
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#f8f8f8">学员名称</td>
                            <td><?= $student->name ?></td>
                            <td bgcolor="#f8f8f8">性别</td>
                            <td><?= $student->sex == 1 ? '男' : '女' ?></td>
                            <td bgcolor="#f8f8f8">年龄</td>
                            <td>
                                <?php
                                $now = date('Y');
                                if (!empty($student->birthday)) {
                                    echo $now - date('Y', strtotime($student->birthday));
                                }
                                ?>岁
                            </td>
                            <td bgcolor="#f8f8f8">血型</td>
                            <td><?= $student->blood_type ?></td>
                            <td bgcolor="#f8f8f8">身份证号码</td>
                            <td><?= $student->IDcard ?></td>
                        </tr>
                        <tr>
                            <td bgcolor="#f8f8f8">父亲电话</td>
                            <td><?= $student->father_phone ?></td>
                            <td bgcolor="#f8f8f8">父亲单位</td>
                            <td><?= $student->father_company ?></td>
                            <td bgcolor="#f8f8f8">母亲电话</td>
                            <td><?= $student->mother_phone ?></td>
                            <td bgcolor="#f8f8f8">母亲单位</td>
                            <td><?= $student->mother_company ?></td>
                            <td bgcolor="#f8f8f8">已学科目</td>
                            <td><?= $student->finish_studying ?></td>
                        </tr>
                        <tr>
                            <td bgcolor="#f8f8f8">感兴趣科目</td>
                            <td><?= $student->intention_studying ?></td>
                            <td bgcolor="#f8f8f8">渠道来源</td>
                            <td><?= $student->source ?></td>
                            <td bgcolor="#f8f8f8">第一联系人</td>
                            <td><?= $student->main_contacts ?></td>
                            <td bgcolor="#f8f8f8">第一联系人电话</td>
                            <td><?= $student->main_phone ?></td>
                            <td bgcolor="#f8f8f8">兴趣爱好</td>
                            <td><?= $student->hobby ?></td>
                        </tr>
                        <tr>
                            <td bgcolor="#f8f8f8">父母公司类型</td>
                            <td><?= $student->company_type ?></td>
                            <td bgcolor="#f8f8f8">学校/幼儿园</td>
                            <td><?= $student->school ?></td>
                            <td bgcolor="#f8f8f8">家庭住址</td>
                            <td colspan="4"><?= $student->address ?></td>
                            <td colspan="3" style="padding:5px 16px 8px 12px; text-align: right;">
                                <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'bind', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bg89c997 yx-width78 yx-mr5 yx-mb0 yx-radius2 yx-md-btn', 'data' => ['id' => \Yii::$app->request->get('id'), 'name' => '编辑学员']]); ?>
                                <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'print', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bg88abda yx-width78 yx-mr0 yx-mb0 yx-radius2', 'data' => ['id' => \Yii::$app->request->get('id'), 'name' => '打印胸牌','btn1'=>'<span id="prints">打印</span>']]); ?>
                            </td>
                        </tr>
                    <?php else : ?>
                        <tr>
                            <td colspan="10"
                                style="text-align: right"><?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'bind', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bg88abda yx-width78 yx-radius2', 'data' => ['id' => \Yii::$app->request->get('id'), 'name' => '编辑学员']]); ?></td>
                        </tr>
                    <?php endif; ?>
                </table>
            </div>

            <div class="yx-member-info" style="border-bottom: none;">
                <div class="">
                    <h3 class="yx-pb15">课程订单：</h3>
                    <div class="yx-member-box">
                        <?php foreach ($orders as $k => $item): ?>
                            <div class="yx-class-list yx-radius2 yx-floatl yx-mr16"><img
                                        src="/images/images/noperson.png" width="83" height="83"
                                        class="yx-border1 img-circle">
                                <ul>
                                    <li>订单号：<?= $item['sn'] ?></li>
                                    <li>联系电话：<?= $item['telephone'] ?></li>
                                    <li>订单金额：<?= $item['total_amount'] ?></li>
                                    <li>预约时间：<?= \Yii::$app->formatter->asDatetime($item['created_at']); ?></li>
                                    <li>课程名称：<?= $item['goods_name'] ?></li>
                                    <div class="yx-course-time-list">
                                    <?php foreach ($item['class_time'] as $v) { ?>
                                        <li>上课时间：<?= $v ?></li>
                                    <?php } ?>
                                        <span class="yx-course-time-arrow">展开</span>
                                    </div>
                                    <li>状 态：<?php
                                        switch ($item['status']) {
                                            case 0:
                                                echo \Yii::t('zhtfrontend', '未确认');
                                                break;
                                            case 1:
                                                echo \Yii::t('zhtfrontend', '已确认');
                                                break;
                                            case 2:
                                                echo \Yii::t('zhtfrontend', '已取消');
                                                break;
                                            case 3:
                                                echo \Yii::t('zhtfrontend', '无效');
                                                break;
                                            case 4:
                                                echo \Yii::t('zhtfrontend', '已退货');
                                                break;
                                            case 5:
                                                echo \Yii::t('zhtfrontend', '部分退货');
                                                break;
                                            case 6:
                                                echo \Yii::t('zhtfrontend', '已完成');
                                                break;
                                            case 7:
                                                echo \Yii::t('zhtfrontend', '转化');
                                                break;
                                            case 8:
                                                echo \Yii::t('zhtfrontend', '续费');
                                                break;
                                        }
                                        ?></li>
                                    <li>支付状态：<?php
                                        switch ($item['pay_status']) {
                                            case 0:
                                                echo \Yii::t('zhtfrontend', '未支付');
                                                break;
                                            case 1:
                                                echo \Yii::t('zhtfrontend', '已支付');
                                                break;
                                            case 2:
                                                echo \Yii::t('zhtfrontend', '已付款至到担保方');
                                                break;
                                            case 3:
                                                echo \Yii::t('zhtfrontend', '部分付款');
                                                break;
                                            case 4:
                                                echo \Yii::t('zhtfrontend', '部分退款');
                                                break;
                                            case 5:
                                                echo \Yii::t('zhtfrontend', '全额退款');
                                                break;
                                            default:
                                                echo \Yii::t('zhtfrontend', '订单支付状态更改');
                                                break;
                                        }
                                        ?></li>
                                </ul>
                                <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'orderitem', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bg79dae3 yx-radius2','style'=>'width:68px;margin-right:5px;', 'data' => ['order_id' => $item['id'], 'name' => '订单课程']]) ?>
                                <?php if ($item['pay_status'] == 0 && !in_array($item['status'], [0, 2])) { ?>
                                    <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'pay', true, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bgfbc74f yx-radius2','style'=>'width:68px;margin-right:5px;', 'data' => ['order_id' => $item['id'], 'id' => \Yii::$app->request->get('id'), 'name' => '订单支付']]) ?>
                                <?php } ?>
                                <?php if ($item['status'] == 0) { ?>
                                    <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'conformcourse', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bgfbc74f yx-radius2','style'=>'width:68px;margin-right:5px;', 'data' => ['order_id' => $item['id'], 'name' => '确认订单']]) ?>
                                <?php } ?>
                                <?php if ($item['pay_status'] != 0) { ?>
                                    <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'payinfo', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bgfbc74f yx-radius2','style'=>'width:68px;margin-right:5px;', 'data' => ['order_id' => $item['id'], 'id' => \Yii::$app->request->get('id'), 'name' => '支付信息','btn1'=>'<span id="prints">打印</span>']]) ?>
                                <?php } ?>
                                <?php if ($item['pay_status'] == 1 && $item['status'] == 1) { ?>
                                    <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'renew', true, ['rel' => '', 'class' => 'btn yx-classmagage-about yx-bg7ecef4 yx-radius2 yx-mr5','style'=>'width:68px; margin-right:5px;', 'data' => ['id' => $item['id']]]); ?>
                                <?php } ?>
                            </div>
                        <?php endforeach; ?>
                        <div class="yx-clear"></div>
                    </div>
                </div>
                <?php if ($goodsOrders) { ?>
                    <div class="">
                        <h3 class="yx-pb15">消费实物订单：</h3>
                        <div class="yx-class-box">
                            <?php foreach ($goodsOrders as $k => $item): ?>
                                <div class="yx-class-list yx-radius2 yx-floatl yx-mr16" style="height: 265px"><img
                                            src="/images/images/noperson.png" width="83" height="83"
                                            class="yx-border1 img-circle">
                                    <ul style="height: 145px">
                                        <li>订单号：<?= $item->sn ?></li>
                                        <li>联系电话：<?= $item->telephone ?></li>
                                        <li>订单金额：<?= $item->total_amount ?></li>
                                        <li>消费时间：<?= \Yii::$app->formatter->asDatetime($item->created_at); ?></li>
                                        <li>支付状态：<?php
                                            switch ($item->pay_status) {
                                                case 0:
                                                    echo \Yii::t('zhtfrontend', '未支付');
                                                    break;
                                                case 1:
                                                    echo \Yii::t('zhtfrontend', '已支付');
                                                    break;
                                                case 2:
                                                    echo \Yii::t('zhtfrontend', '已付款至到担保方');
                                                    break;
                                                case 3:
                                                    echo \Yii::t('zhtfrontend', '部分付款');
                                                    break;
                                                case 4:
                                                    echo \Yii::t('zhtfrontend', '部分退款');
                                                    break;
                                                case 5:
                                                    echo \Yii::t('zhtfrontend', '全额退款');
                                                    break;
                                                default:
                                                    echo \Yii::t('zhtfrontend', '订单支付状态更改');
                                                    break;
                                            }
                                            ?></li>
                                    </ul>
                                    <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'orderitem', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bgfbc74f yx-radius2 yx-width47', 'data' => ['order_id' => $item->id, 'name' => '查看', 'title' => '查看商品']]) ?>
                                    <?php if ($item->pay_status == 0 && $item->status == 1) { ?>
                                        <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'payproduct', true, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bgfbc74f yx-radius2 yx-width47', 'data' => ['id' => $item->id, 'name' => '支付']]) ?>
                                    <?php } ?>
                                    <?php if ($item->pay_status > 0 && $item->status == 1) { ?>
                                        <?= (new MenuManage(MenuManage::TOP_MENU))->detailsMenu('customer', 'payinfo', false, ['rel' => 'dialog-show-iframe', 'class' => 'btn yx-classmagage-about yx-bgfbc74f yx-radius2 yx-width47', 'data' => ['order_id' => $item->id, 'id' => \Yii::$app->request->get('id'), 'name' => '支付信息']]) ?>
                                    <?php } ?>
                                </div>
                            <?php endforeach; ?>
                            <div class="yx-clear"></div>
                        </div>
                    </div>
                <?php } ?>
            </div>


        </div>
    </div>
    <input type="hidden" value="<?= !empty($student) ? $student->name : '' ?>" id="student_name">
<?php
$js = <<<JS
    $(document).on('click','a[rel="consume"]',function(){
    var name = $('#student_name').val();
    var url = $(this).data('url');
        if (name.length == 0) {
            layer.msg("请先编辑学员信息！",{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
            return false;
        }else{
            window.location.href=url;
        }

   });
JS;
$this->registerJs($js);
?>